package com.cards_game.simple_ddz.service.impl;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.stereotype.Service;

import com.cards_game.simple_ddz.bean.BaseCardBean;
import com.cards_game.simple_ddz.bean.KingCardBean;
import com.cards_game.simple_ddz.bean.SimpleDdzBean;
import com.cards_game.simple_ddz.common.AllPrimaryContainer;
import com.cards_game.simple_ddz.common.RoomBean;
import com.cards_game.simple_ddz.constants.CardConstants;
import com.cards_game.simple_ddz.service.StartGameService;

/**
 * @author 郭国辉
 * 
 *     2017年6月22日下午6:20:51
 */
@Service
public class StartGameServiceImpl implements StartGameService {
	private ConcurrentHashMap<Integer, RoomBean> map = AllPrimaryContainer.getAllPrimaryContainer().getAllRoomMap();
//	private ConcurrentSkipListSet<RoomBean> notFullRooms = AllPrimaryContainer.getAllPrimaryContainer().getNotFullRooms();
	
	/**
	 * @param roomId
	 * @return
	 */
	@Override
	public List<SimpleDdzBean> dealCards(String roomId) {
		RoomBean rb=map.get(roomId);
		List<SimpleDdzBean> list = rb.getOriginalCards();
		for (CardConstants.Number num : CardConstants.Number.values()) {
			for (CardConstants.Suits suit : CardConstants.Suits.values()) {
				SimpleDdzBean bcb = new SimpleDdzBean();
				bcb.setNum(num.getValue());
				bcb.setSuit(suit);
				list.add(bcb);
			}
		}
		SimpleDdzBean MaxKing = new SimpleDdzBean();
		MaxKing.setJoker(CardConstants.Joker.Max);
		list.add(MaxKing);
		SimpleDdzBean MinKing = new SimpleDdzBean();
		MinKing.setJoker(CardConstants.Joker.Min);
		list.add(MinKing);
		
		return list;
	}

}
